package com.ruoyi.wms.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.wms.mapper.WmsWarehouseStaffMapper;
import com.ruoyi.wms.domain.WmsWarehouseStaff;
import com.ruoyi.wms.service.IWmsWarehouseStaffService;

/**
 * 仓库员工Service业务层处理
 * 
 * @author ruoyi
 * @date 2024-01-01
 */
@Service
public class WmsWarehouseStaffServiceImpl implements IWmsWarehouseStaffService 
{
    @Autowired
    private WmsWarehouseStaffMapper wmsWarehouseStaffMapper;

    /**
     * 查询仓库员工
     * 
     * @param id 仓库员工主键
     * @return 仓库员工
     */
    @Override
    public WmsWarehouseStaff selectWmsWarehouseStaffById(Long id)
    {
        return wmsWarehouseStaffMapper.selectWmsWarehouseStaffById(id);
    }

    /**
     * 查询仓库员工列表
     * 
     * @param wmsWarehouseStaff 仓库员工
     * @return 仓库员工
     */
    @Override
    public List<WmsWarehouseStaff> selectWmsWarehouseStaffList(WmsWarehouseStaff wmsWarehouseStaff)
    {
        // 设置租户ID
        wmsWarehouseStaff.setTenantId(SecurityUtils.getTenantId());
        return wmsWarehouseStaffMapper.selectWmsWarehouseStaffList(wmsWarehouseStaff);
    }

    /**
     * 新增仓库员工
     * 
     * @param wmsWarehouseStaff 仓库员工
     * @return 结果
     */
    @Override
    public int insertWmsWarehouseStaff(WmsWarehouseStaff wmsWarehouseStaff)
    {
        wmsWarehouseStaff.setTenantId(SecurityUtils.getTenantId());
        wmsWarehouseStaff.setCreateBy(SecurityUtils.getUsername());
        wmsWarehouseStaff.setCreateTime(DateUtils.getNowDate());
        return wmsWarehouseStaffMapper.insertWmsWarehouseStaff(wmsWarehouseStaff);
    }

    /**
     * 修改仓库员工
     * 
     * @param wmsWarehouseStaff 仓库员工
     * @return 结果
     */
    @Override
    public int updateWmsWarehouseStaff(WmsWarehouseStaff wmsWarehouseStaff)
    {
        wmsWarehouseStaff.setUpdateBy(SecurityUtils.getUsername());
        wmsWarehouseStaff.setUpdateTime(DateUtils.getNowDate());
        return wmsWarehouseStaffMapper.updateWmsWarehouseStaff(wmsWarehouseStaff);
    }

    /**
     * 批量删除仓库员工
     * 
     * @param ids 需要删除的仓库员工主键
     * @return 结果
     */
    @Override
    public int deleteWmsWarehouseStaffByIds(Long[] ids)
    {
        return wmsWarehouseStaffMapper.deleteWmsWarehouseStaffByIds(ids);
    }

    /**
     * 删除仓库员工信息
     * 
     * @param id 仓库员工主键
     * @return 结果
     */
    @Override
    public int deleteWmsWarehouseStaffById(Long id)
    {
        return wmsWarehouseStaffMapper.deleteWmsWarehouseStaffById(id);
    }

    /**
     * 根据用户ID查询仓库员工列表
     * 
     * @param userId 用户ID
     * @return 仓库员工集合
     */
    @Override
    public List<WmsWarehouseStaff> selectWmsWarehouseStaffByUserId(Long userId)
    {
        return wmsWarehouseStaffMapper.selectWmsWarehouseStaffByUserId(userId, SecurityUtils.getTenantId());
    }

    /**
     * 根据仓库ID查询员工列表
     * 
     * @param warehouseId 仓库ID
     * @return 仓库员工集合
     */
    @Override
    public List<WmsWarehouseStaff> selectWmsWarehouseStaffByWarehouseId(Long warehouseId)
    {
        return wmsWarehouseStaffMapper.selectWmsWarehouseStaffByWarehouseId(warehouseId, SecurityUtils.getTenantId());
    }
}